#include<stdio.h>
#include<sys/types.h>
#include<sys/ipc.h>
#include<unistd.h>
#include<fcntl.h>
#include<sys/shm.h>
#include"comm.h"

int main()
{
  key_t k = ftok(PATHNAME,PROJ_ID);
  printf("key :%d\n",k);

  int shmid = shmget(k,SIZE,IPC_CREAT|IPC_EXCL|0666);
  if(shmid<0){
    perror("shmget");
    return 1;
  }
  
  printf("shmid:%d\n",shmid);

  char *str = (char*)shmat(shmid,NULL,0);
    
  int i = 0;
  while(i++ < 26){
    printf("client # %s\n",str);
    sleep(2);
  }
  shmdt(str);
  shmctl(shmid,IPC_RMID,NULL);
  
  return 0;
}
